/**
 * 用户相关的数据store
 */
import { defineStore } from 'pinia'

import { ref } from 'vue'

import type { User } from '@/types/user'
export const useUserStore = defineStore('cp-uset', ()=>{
   //空对象的变量通过as断言
  const user = ref({} as User)
  //存储用户信息
  const setUser = (data: User) => {
    user.value = data
  }
  //清除用户信息，设置为空对象
  const clearUser = () => {
    user.value = {} as User
  }
  return{
    user,
    setUser,
    clearUser
  }
}, {
  persist: true
})


